import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import refresh from '@feidao/web/atom/browser/url/refresh';
export default async function ca016(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	// 单选框确定radio
	const query = fd.data.params;
	delete query['page-no'];
	// const q = (query.param || (query.param = {}));
	const param = query.param && JSON.parse(query.param);
	const q = param ? param : {};
	const key = args[0].target.dataset.feidaoId;

	const radios = fd.data.node.querySelectorAll<HTMLInputElement>('[data-feidao-id=radio_' + key + ']');

	const radio_check = Array.from(radios).filter((i) => {
		return i.checked;
	});
	if (radio_check.length > 0) {
		const value = radio_check[0].value;
		q[key] = value;
		query.param = JSON.stringify(q);
		refresh(query);

	} else {
		q[key] = '';
		query.param = JSON.stringify(q);
		refresh(query);
	}
}
